package com.hjxr.xmgl.web.controller;

import com.hjxr.xmgl.web.domain.Event;
import com.hjxr.xmgl.web.service.EventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author: xk
 * @create: 2021-11-26 11:27
 * @description:
 **/
@Api("事件管理")
@RestController
public class  EventController {

    @Autowired
    private EventService EventService;

    @ApiOperation("查询全部事件")
    @GetMapping(value = "/selectall")
    @ResponseBody
    public List<Map<String,Object>> selectAll(){
        return EventService.selectAll();
    }


    @ApiOperation("查询一件事件")
    @GetMapping(value = "/selectById")
    @ResponseBody
    public Event selectById(Integer eventId){
        return EventService.selectById(eventId);
    }

    @ApiOperation("插入事件")
    @PostMapping(value = "/insertEvent")
    @ResponseBody
    public int insertEvent(Event event){
        return EventService.insertEvent(event);
    }

    @ApiOperation("更新事件")
    @PostMapping(value = "/updateEvent")
    @ResponseBody
    public int updateEvent(Event event){
        return EventService.updateEvent(event);
    }

    @ApiOperation("删除事件")
    @GetMapping(value = "/deleteEventById")
    @ResponseBody
    public int deleteEventById(Integer eventId){
        return EventService.deleteEventById(eventId);
    }
}
